import pandas as pd

def age_18_to_30(a):
    return a >= 18 and a < 30
# python中独有的写法
def age_18_to_30(a):
    return 18 <= a < 30

def level_a(a):
    return 85 <= a <= 100

student = pd.read_excel('student.xlsx', index_col='ID')
# student = student.loc[student['age'].apply(age_18_to_30)].loc[student['Score'].apply(level_a)]
# student = student.loc[student.age.apply(age_18_to_30)].loc[student.Score.apply(level_a)]
# “\”换行显示
student = student.loc[student['age'].apply(lambda a: 18 <= a < 30 )]\
    .loc[student['Score'].apply(lambda a: 85 <= a <= 100)]
print(student)